<?php
/**
 * Created by Zhy
 * User: Zhy
 * Date: 2019/3/13
 * Time: 15:10
 */

namespace app\admin\controller;


use think\Db;

class Recharge extends Base
{
    /**
     * @return mixed|\think\response\Json
     * 展示
     */
    public function index(){
        if(request()->isAjax ()){
            $params = input('param.');
            $where = [];
            //包类型
            if(isset($params['order_type']) && $params['order_type'] != ''){
                $where['order_type'] = $params['order_type'];
            }else{
                $where['order_type'] = [['=', '2'], ['=', '3'], 'or'];
            }
            //昵称
            if(isset($params['user_username']) && $params['user_username'] != ''){
                $where['user_username'] = ['like', "%" . $params['user_username'] . "%"];
            }
            
            $Nowpage = input('page') ? input('page') : 1;
            $limits = input("limit") ? input("limit") : 10;
            $count = Db::name('order')
                ->join('up_u_user', 'user_id = order_user_id', 'left')
                ->where($where)
                ->count();// 获取总条数
            $lists = Db::name('order')
                ->join('up_u_user', 'user_id = order_user_id', 'left')
                ->where($where)
                ->field('order_id, user_image, user_username, user_id, order_num, order_type, 
                order_time, order_money')
                ->page($Nowpage,$limits)
                ->order('order_time desc')
                ->select();
            return json(['code' => 220, 'msg' => '', 'count' => $count, 'data' => $lists]);
        }
        return $this->fetch();
    }
}